import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import locale from 'element-ui/lib/locale/lang/en'
// 导入全局样式
import './assets/css/common.css'
// 导入阿里图标素材
import './assets/fonts/iconfont.css'
import axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'
// 富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import echarts from 'echarts'
// 设置基准的url
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
axios.interceptors.request.use(config => {
  // 请求对象添加Authorization
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
Vue.prototype.$http = axios
Vue.prototype.$echarts = echarts
Vue.config.productionTip = false
Vue.component('tree-table', TreeTable)
Vue.use(VueQuillEditor)
// 过滤时间控制
Vue.filter('dataFormat', function (originVal) {
  const dateTime = new Date(originVal)
  const y = dateTime.getFullYear()
  const m = (dateTime.getMonth() + 1 + '').padStart(2, '0')
  const d = (dateTime.getDay() + '').padStart(2, '0')
  const hous = (dateTime.getHours() + '').padStart(2, '0')
  const minute = (dateTime.getMinutes() + '').padStart(2, '0')
  const ss = (dateTime.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hous}:${minute}:${ss}`
})
new Vue({
  router,
  locale,
  render: h => h(App)
}).$mount('#app')
